<?php
/*
$KDN = new Kuaidiniao();
$arr['express_code'] = 'ZTO';
$arr['express_NO'] = '453428852106';
$arr['back_url'] = 'http://www.163.com';
echo $KDN->getMobileTraceUrl($arr);
*/

class Kuaidiniao {
  private $arr_express;
  // 电子面单
  private $express_order_url_test = 'http://sandboxapi.kdniao.com:8080/kdniaosandbox/gateway/exterfaceInvoke.json';
  private $express_order_url = 'http://api.kdniao.com/api/EOrderService';
  private $express_order_cancal_url_test = 'http://sandboxapi.kdniao.com:8080/kdniaosandbox/gateway/exterfaceInvoke.json';
  private $express_order_cancal_url = 'http://api.kdniao.com/api/EOrderService';

  function __construct()
  {
    $this->arr_express = $this->returnExpress();
  }

  // 下单类接口


  // 外部调用
  function getMobileTraceUrl($arr) {
    $arr['sort'] = isset($arr['sort']) ? $arr['sort'] : 'DESC';
    $arr['color'] = isset($arr['color']) ? $arr['color'] : 'rgb(46,114,251)';
    $arr['back_url'] = isset($arr['back_url']) ? $arr['back_url'] : 'javascript:;';
    return 'http://www.kdniao.com/JSInvoke/MSearchResult.aspx?expCode='.$arr['express_code'].'&expNo='.$arr['express_NO'].'&sortType='.$arr['sort'].'&color='.$arr['color'].'&backUrl='.$arr['back_url'];
  }

  function getPCTraceUrl($arr) {
    return 'http://www.kdniao.com/JSInvoke/SearchResult.aspx?expCode='.$arr['express_code'].'&expNo='.$arr['express_NO'];
  }

  function getPCTraceIframe($arr) {
    return '<iframe width="900" height="550" border="0" frameborder="0" scrolling="no" src="http://www.kdniao.com/JSInvoke/SearchResult.aspx?expCode='.$arr['express_code'].'&expNo='.$arr['express_NO'].'"></iframe>';
  }

  static function returnExpress() {
    return array(
      "SF"=>"顺丰速运",
      "HTKY"=>"百世快递",
      "ZTO"=>"中通快递",
      "STO"=>"申通快递",
      "YTO"=>"圆通速递",
      "YD"=>"韵达速递",
      "YZPY"=>"邮政快递包裹",
      "EMS"=>"EMS",
      "HHTT"=>"天天快递",
      "JD"=>"京东快递",
      "UC"=>"优速快递",
      "DBL"=>"德邦快递",
      "ZJS"=>"宅急送",
      "TNT"=>"TNT快递",
      "UPS"=>"UPS",
      "DHL"=>"DHL",
      "FEDEX"=>"FEDEX联邦(国内件）",
      "FEDEX_GJ"=>"FEDEX联邦(国际件）"
    );
  }
}
